package o;

import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioProcessor.UnhandledFormatException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public final class acm implements AudioProcessor {
    private static final int ˎ = Float.floatToIntBits(Float.NaN);
    private ByteBuffer ʻ = ˏ;
    private int ˊ = -1;
    private int ˋ = -1;
    private int ॱ = 0;
    private boolean ॱॱ;
    private ByteBuffer ᐝ = ˏ;

    public boolean ˋ(int i, int i2, int i3) throws UnhandledFormatException {
        if (!anr.ॱ(i3)) {
            throw new UnhandledFormatException(i, i2, i3);
        } else if (this.ˊ == i && this.ˋ == i2 && this.ॱ == i3) {
            return false;
        } else {
            this.ˊ = i;
            this.ˋ = i2;
            this.ॱ = i3;
            return true;
        }
    }

    public boolean ˏ() {
        return anr.ॱ(this.ॱ);
    }

    public int ˋ() {
        return this.ˋ;
    }

    public int ˊ() {
        return 4;
    }

    public int ˎ() {
        return this.ˊ;
    }

    public void ˎ(ByteBuffer byteBuffer) {
        Object obj = this.ॱ == 1073741824 ? 1 : null;
        int position = byteBuffer.position();
        int limit = byteBuffer.limit();
        int i = limit - position;
        if (obj == null) {
            i = (i / 3) * 4;
        }
        if (this.ᐝ.capacity() < i) {
            this.ᐝ = ByteBuffer.allocateDirect(i).order(ByteOrder.nativeOrder());
        } else {
            this.ᐝ.clear();
        }
        if (obj != null) {
            while (position < limit) {
                ˏ((((byteBuffer.get(position) & 255) | ((byteBuffer.get(position + 1) & 255) << 8)) | ((byteBuffer.get(position + 2) & 255) << 16)) | ((byteBuffer.get(position + 3) & 255) << 24), this.ᐝ);
                position += 4;
            }
        } else {
            for (int i2 = position; i2 < limit; i2 += 3) {
                ˏ((((byteBuffer.get(i2) & 255) << 8) | ((byteBuffer.get(i2 + 1) & 255) << 16)) | ((byteBuffer.get(i2 + 2) & 255) << 24), this.ᐝ);
            }
        }
        byteBuffer.position(byteBuffer.limit());
        this.ᐝ.flip();
        this.ʻ = this.ᐝ;
    }

    public void ॱ() {
        this.ॱॱ = true;
    }

    public ByteBuffer ʽ() {
        ByteBuffer byteBuffer = this.ʻ;
        this.ʻ = ˏ;
        return byteBuffer;
    }

    public boolean ʻ() {
        return this.ॱॱ && this.ʻ == ˏ;
    }

    public void ʼ() {
        this.ʻ = ˏ;
        this.ॱॱ = false;
    }

    public void ᐝ() {
        ʼ();
        this.ˊ = -1;
        this.ˋ = -1;
        this.ॱ = 0;
        this.ᐝ = ˏ;
    }

    private static void ˏ(int i, ByteBuffer byteBuffer) {
        int floatToIntBits = Float.floatToIntBits((float) (4.656612875245797E-10d * ((double) i)));
        if (floatToIntBits == ˎ) {
            floatToIntBits = Float.floatToIntBits(0.0f);
        }
        byteBuffer.putInt(floatToIntBits);
    }
}
